import 'package:flutter_study/mvp/prsenter/ipresenter/icontact_prsenter.dart';
import 'package:flutter_study/mvp/view/iview/icontact_page.dart';

import '../bean/contact.dart';
import '../contact_data_impl.dart';

class ContactPresenter implements Presenter{

  View _view;

  ContactRepository _repository;

  ContactPresenter(this._view){
    _view.setPresenter(this);
  }

  @override
  void loadContacts(){
    assert(_view!= null);

    _repository.fetch().then(
            (contacts){
          _view.onLoadContactsComplete(contacts);
        })
        .catchError((error){
      print(error);
      _view.onLoadContactsError();
    }
    );
  }
  @override
  init() {
    _repository = new MockContactRepository();
  }
}